import java.io.IOException;
import java.net.*;

public class Main {

    public static void main(String[] args) throws InterruptedException, IOException {
        new Thread(() -> new UDPServer().startServer()).start();

//        Thread.sleep(2000);
        DatagramSocket socket = new DatagramSocket();
        for (int i = 1; i <= 4;i++) {
            byte[] bytes;
            if (i == 4) {
                bytes = "exit".getBytes();
            } else {
                bytes = ("第" + i + "次：Hello").getBytes();
            }
            DatagramPacket packet = new DatagramPacket(
                    bytes,
                    bytes.length,
                    InetAddress.getLocalHost(),
                    6666);
            socket.send(packet);
        }
        socket.close();
    }
}
